import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import React, { PureComponent } from 'react';
import { Radio, InputNumber, List, Checkbox } from 'antd';
var Group = Radio.Group;

var Hour = /*#__PURE__*/function (_PureComponent) {
  _inherits(Hour, _PureComponent);

  var _super = _createSuper(Hour);

  function Hour(props) {
    var _this;

    _classCallCheck(this, Hour);

    _this = _super.call(this, props);

    _this.changeType = function (e) {
      var state = _objectSpread({}, _this.props.month); // if (e.target.value === 'some') {
      //   state.some = ['1'];
      // }


      state.type = e.target.value;

      _this.props.onChange(state);
    };

    _this.formatHourOptions();

    return _this;
  }

  _createClass(Hour, [{
    key: "formatHourOptions",
    value: function formatHourOptions() {
      this.hourOptions = [];

      for (var x = 0; x < 24; x++) {
        this.hourOptions.push({
          label: x < 10 ? "0".concat(x) : x,
          value: "".concat(x)
        });
      }
    }
  }, {
    key: "changeParams",
    value: function changeParams(type, value) {
      var state = _objectSpread({}, this.props.hour);

      state[type] = value;
      this.props.onChange(state);
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var _this$props$hour = this.props.hour,
          type = _this$props$hour.type,
          start = _this$props$hour.start,
          end = _this$props$hour.end,
          begin = _this$props$hour.begin,
          some = _this$props$hour.some,
          beginEvery = _this$props$hour.beginEvery;
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Group, {
        value: type,
        onChange: this.changeType
      }, /*#__PURE__*/React.createElement(List, {
        size: "small",
        bordered: true
      }, /*#__PURE__*/React.createElement(List.Item, null, /*#__PURE__*/React.createElement(Radio, {
        value: "*"
      }, "\u6BCF\u5C0F\u65F6")), /*#__PURE__*/React.createElement(List.Item, {
        style: {
          marginBottom: 5
        }
      }, /*#__PURE__*/React.createElement(Radio, {
        value: "period"
      }, "\u5468\u671F"), "\u4ECE \xA0", /*#__PURE__*/React.createElement(InputNumber, {
        min: 0,
        max: 24,
        defaultValue: 0,
        style: {
          width: 80
        },
        placeholder: "\u65F6",
        size: "small",
        value: start,
        onChange: function onChange(value) {
          _this2.changeParams('start', value);
        }
      }), "\xA0\u5230\xA0", /*#__PURE__*/React.createElement(InputNumber, {
        min: 0,
        max: 24,
        defaultValue: 24,
        style: {
          width: 80
        },
        placeholder: "\u65F6",
        value: end,
        size: "small",
        onChange: function onChange(value) {
          _this2.changeParams('end', value);
        }
      })), /*#__PURE__*/React.createElement(List.Item, null, /*#__PURE__*/React.createElement(Radio, {
        value: "beginInterval"
      }), "\u4ECE\u7B2C\xA0", /*#__PURE__*/React.createElement(InputNumber, {
        min: 0,
        max: 24,
        defaultValue: 0,
        placeholder: "\u65F6",
        size: "small",
        value: begin,
        onChange: function onChange(value) {
          _this2.changeParams('begin', value);
        }
      }), "\xA0\u65F6\u5F00\u59CB\uFF0C \xA0\u6BCF\xA0", /*#__PURE__*/React.createElement(InputNumber, {
        min: 0,
        max: 24,
        defaultValue: 1,
        placeholder: "\u5C0F\u65F6",
        size: "small",
        value: beginEvery,
        onChange: function onChange(value) {
          _this2.changeParams('beginEvery', value);
        }
      }), "\xA0\u65F6\u6267\u884C\u4E00\u6B21"), /*#__PURE__*/React.createElement(List.Item, null, /*#__PURE__*/React.createElement(Radio, {
        value: "some"
      }, "\u6307\u5B9A"), /*#__PURE__*/React.createElement(Checkbox.Group, {
        value: some,
        onChange: function onChange(value) {
          // if (value.length < 1) {
          //   return message.warn('至少选择一项');
          // }
          _this2.changeParams('some', value);
        },
        options: this.hourOptions
      })))));
    }
  }]);

  return Hour;
}(PureComponent);

export { Hour as default };